package com.magneticattraction.testnfc;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

public class SensorReceiver extends BroadcastReceiver {

    private String sensor;

    @Override
    public void onReceive(Context context, Intent intent) {
        //接收服务端发送的广播
        String result = intent.getStringExtra("sensor");
        System.out.println("receiver result is" + result);
        Log.e("SensorReceiver", "receiver result is" + result);
        Toast.makeText(context, "result is" + result, Toast.LENGTH_SHORT).show();
        this.sensor = result;
    }

    //返回广播接收到的数据
    public String getSensor() {
        return this.sensor;
    }
}